// app.js
// api
const $api = require('./utils/request.js').Api;
App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    const openIdWy = wx.getStorageSync("openIdWy") || ""
    // 登录
    wx.login({
      success: res => {
        if(!openIdWy){
          $api.getOpenId(res.code).then((result) => {
            wx.setStorageSync('openIdWy', result.openId)
          }).catch((error) => {
            wx.showToast({
              title: error.message,
              icon: 'error',
              duration: 3000
            });
          });
        }
      }
    })
  },
  globalData: {
    userInfo: null
  }
})
